/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.nxlv2.nomad.accessdb.services;

import com.nxlv2.nomad.accessdb.dao.IAdresseDao;
import com.nxlv2.nomad.accessdb.dao.IClientDao;
import com.nxlv2.nomad.accessdb.dao.jdbc.JdbcAdresseDao;
import com.nxlv2.nomad.accessdb.dao.jdbc.JdbcClientDao;
import com.nxlv2.nomad.businessobjects.Adresse;
import com.nxlv2.nomad.businessobjects.Client;

/**
 *
 * @author Nastasia
 */
public class AdresseServices {
    private static final  IAdresseDao daoA = new JdbcAdresseDao();
    private static final IClientDao daoC = new JdbcClientDao();
    
    /**
     * 
     * @param adresse
     * @param client
     * @throws ServiceException 
     */
    public void create(Adresse adresse, Client client) throws ServiceException {
        daoA.saveAdresse(adresse);
        daoC.lierAdresseAClient(adresse, client);
    }
    
    /**
     * 
     * @param adresse
     * @throws ServiceException 
     */
    public void update(Adresse adresse) throws ServiceException {
        daoA.updateAdresse(adresse);
    }
    
    /**
     * 
     * @param adresse
     * @throws ServiceException 
     */
    public void delete(Adresse adresse) throws ServiceException {
        daoA.deleteAdresse(adresse.getIdAppli());
    }
    
    /**
     * 
     * @param id
     * @return
     * @throws ServiceException 
     */
    public Adresse get(int id) throws ServiceException {
        return daoA.findAdresseById(id);
    }
    
}
